package com.byxy.managerial.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.byxy.managerial.entity.Department;
import com.byxy.managerial.service.DepartmentService;
import com.opensymphony.xwork2.ActionSupport;

public class DepartmentListAction extends ActionSupport {
	private static final long serialVersionUID = 1L;

	private Integer pos;// 分页下标，0开始
	private Integer row;// 多少列
	private Integer total;// 总数
	private String search;// 模糊搜索的值
	private Map<String, Object> result = new HashMap<String, Object>();
	private List<Department> list;
	@Resource
	private DepartmentService departmentService;

	@Override
	public String execute() throws Exception {
		total = departmentService.countTotal();
		return SUCCESS;
	}

	public String getDepartList() {
		if (search == "") {//值为空就不是搜索
			System.out.println("我是哈哈哈"+pos+row);
			List<Department> list = departmentService.find(pos, row);// 获取分页数据
			result.put("total", total);
			result.put("list", list);
		}
		else {
			List<Department> list = departmentService.findDim(search);// 模糊查询数据
			result.put("total", total);
			result.put("list", list);
		}
		return SUCCESS;
	}

	public List<Department> getList() {
		return list;
	}

	public void setList(List<Department> list) {
		this.list = list;
	}

	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}

	public Map<String, Object> getResult() {
		return result;
	}

	public void setResult(Map<String, Object> result) {
		this.result = result;
	}

	public Integer getPos() {
		return pos;
	}

	public void setPos(Integer pos) {
		this.pos = pos;
	}

	public Integer getRow() {
		return row;
	}

	public void setRow(Integer row) {
		this.row = row;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}
	
	

}
